package com.fis.hlo.pm.client;

import java.net.URL;

import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;

import org.apache.cxf.endpoint.Client;
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.transport.http.HTTPConduit;
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;

import com.fis.hlo.pm.summarize.PMSummarizeTransferer;
import com.fis.hlo.pm.summarize.PMSummarizeTransfererService;
import com.fis.mca.config.Config;
import com.fis.mca.config.ConfigConstant;
import com.sun.xml.internal.ws.client.BindingProviderProperties;

public class SummarizeTransfererClient {
	private static final QName SERVICE_NAME = new QName(
			"http://summarize.pm.hlo.fis.com/", "PMSummarizeTransfererService");
	private static final String WSDL_URL = Config
			.getURL(ConfigConstant.PM_SUMMARIZE_PORT_KEY);

	public static PMSummarizeTransferer getService() throws Exception {
		URL url = new URL(WSDL_URL);
		PMSummarizeTransfererService ss = new PMSummarizeTransfererService(url,
				SERVICE_NAME);
		PMSummarizeTransferer port = ss.getPMSummarizeTransfererPort();

		Client client = ClientProxy.getClient(port);
		HTTPConduit http = (HTTPConduit) client.getConduit();
		HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
		// httpClientPolicy.setConnectionTimeout((15 * 60) * 1000);
		httpClientPolicy.setReceiveTimeout((15 * 60) * 1000);

		httpClientPolicy.setAllowChunking(false);
		http.setClient(httpClientPolicy);

		return port;
	}
}
